import request from 'umi-request';
import type { User } from 'src/types/openapi';

export async function getUserList() {
  return request<User[]>('/api/users');
}

export async function getUserById(id: string) {
  return request<User>(`/api/users/${id}`);
}

export async function createUser(data: User) {
  return request<boolean>('/api/users', {
    method: 'POST',
    data,
  });
}

export async function updateUser(data: User) {
  return request<boolean>('/api/users', {
    method: 'PUT',
    data,
  });
}

export async function deleteUser(id: string) {
  return request<boolean>(`/api/users/${id}`, {
    method: 'DELETE',
  });
}
